package com.hdoit.apollo.logical.purchase.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.hdoit.apollo.logical.purchase.dao.IPurchaseCollocationDao;
import com.hdoit.apollo.logical.purchase.mapper.PurchaseCollocationMapper;
import com.hdoit.apollo.logical.purchase.model.PurchaseCollocation;
import com.tennetcn.data.dao.base.ISqlExpression;
import com.tennetcn.data.dao.base.impl.SuperDao;
import com.tennetcn.data.utils.SqlExpressionFactory;
/**
 * @author      humaoshu
 * @email       
 * @createtime  2018年05月23日 11:01:26
 * @comment
 */
@Component
public class PurchaseCollocationDaoImpl extends SuperDao<PurchaseCollocation> implements IPurchaseCollocationDao{

	@Autowired
	private PurchaseCollocationMapper purchaseCollocationMapper;
	
	@Override
	public boolean deletePurchaseCollocations(String purchaseId) {
		ISqlExpression sqlExpression = SqlExpressionFactory.createExpression();
		sqlExpression.addBody("delete from",PurchaseCollocation.class)
					.andWhere("purchaseId=#{purchaseId}")
					.setParam("purchaseId", purchaseId);
		return delete(sqlExpression)>=0;
	}

	@Override
	public List<PurchaseCollocation> getListByIds(String[] purchaseCollocationIds) {

		return purchaseCollocationMapper.getListByIds(purchaseCollocationIds);
	}

	@Override
	public PurchaseCollocation queryModelById(String purchaseCollocationId) {
		return purchaseCollocationMapper.queryModelById(purchaseCollocationId);
	}

	@Override
	public List<PurchaseCollocation> queryListByPurchaseId(String purchaseId) {
		
		return purchaseCollocationMapper.queryListByPurchaseId(purchaseId);
	}


	@Override
	public PurchaseCollocation queryModelByCollocationId(String collocationId,
			String purchaseId) {
		
		return purchaseCollocationMapper.queryModelByCollocationId(collocationId,purchaseId);
	}

}